package com.tomecode.tools.maven.settings.util;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * backup file info
 * 
 * @author Frastia Tomas
 * 
 */
public final class Backup {
	/**
	 * real backup file
	 */
	private final File file;
	/**
	 * create date
	 */
	private String date;

	public Backup(File file) {
		this.file = file;
		int index = file.getName().lastIndexOf(".xml_backup_");
		try {
			date = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss").format(new Date(Long.valueOf(file.getName().substring(index + ".xml_backup_".length()))));
		} catch (Exception e) {
			date = file.getName();
		}
	}

	public final File getFile() {
		return file;
	}

	public final String toString() {
		return date;
	}
}
